import 'dart:math';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:fluttertoast/fluttertoast.dart';
import '../pages/comm/view_page.dart';
import 'package:flutter/services.dart';
import '../pages/comm/method_bridge.dart';

class Tile extends StatelessWidget {
  const Tile({super.key, this.index, required this.model});

  final int? index;
  final Map<String, dynamic> model;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

    // 创建 Random 对象
    Random random = Random();

    // 生成 1 到 9 之间的随机整数
    int randomNumber = random.nextInt(20);

    return InkWell(
      onTap: () {
        //Get.toNamed("/Message/1");
        MethodBridge.getInstance().showLiveVc(model);
        // MethodBridge.getInstance().showTip("This is a Toast message");
        // Get.to(ViewPage(index: index));
      },
      child: Container(
        decoration: BoxDecoration(
          color: Color.fromARGB(255, 197, 245, 168),
          borderRadius: BorderRadius.circular(8.0),
          image: DecorationImage(
            image: NetworkImage(
              model["coverImg"] ?? "", // 替换为你的图片URL
            ),
            fit: BoxFit.cover,
          ),
          // image: DecorationImage(
          //   image: AssetImage("assets/images/${randomNumber}.jpg"), // 使用本地图片
          //   fit: BoxFit.cover,
          // ),
        ),
      ),
    );
  }
}
